package com.easysoft.framework.action;

import com.easysoft.framework.beans.Page;
import com.easysoft.framework.casereply.model.SysCaseReplyQuery;
import com.easysoft.framework.casereply.model.SysCaseReplyView;
import com.easysoft.framework.consult.model.SysConsultationQuery;
import com.easysoft.framework.consult.model.SysConsultationView;
import com.easysoft.framework.consult.service.SysConsultationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * 咨询表
 *
 *
 */
@RestController
@RequestMapping(value = SystemConsultAction.BASE_VIEW)
public class SystemConsultAction {
    public static final String BASE_VIEW = "/consult";
    private static final Logger logger = LoggerFactory.getLogger(SystemConsultAction.class);

    @Autowired
    @Qualifier("service.SysConsultationService")
    private SysConsultationService sysConsultationService ;

    /**
     * 分页咨询表
     * @param page  分页信息
     * @param query 查询条件
     * @return 咨询列表
     */
    @RequestMapping(value = "/listConsultation", method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView listConsultation(Page page, SysConsultationQuery query) {
        logger.info("Call SysConsultationService.listConsultation({},{})", page.toString(), query.toString());
        List<SysConsultationView> list = sysConsultationService.selectSysConsultationListByPage(query,page);
        ModelAndView mv = new ModelAndView(BASE_VIEW + "/listConsultation");
        mv.addObject("page", page);
        mv.addObject("query", query);
        mv.addObject("listConsultation", list);
        return mv;
    }

}
